/**
 * Created by xiedongfeng on 2017/7/27.
 */

$(function () {
    var $iosActionsheet = $('.dc-nutrition');
    var $iosMask = $('.dc-mask');

    function hideActionSheet() {
        $iosActionsheet.removeClass('dc-nutrition-toggle');
        $iosMask.fadeOut(200);
    }

    function showActionSheet() {
        $iosActionsheet.addClass('dc-nutrition-toggle');
        $iosMask.fadeIn(200);
    }

    $iosMask.on('click', hideActionSheet);

    $('.dc-btn').on('click', function () {
        if(!$iosActionsheet.hasClass('dc-nutrition-toggle')){
            showActionSheet();
        }else if($iosActionsheet.hasClass('dc-nutrition-toggle')){
            hideActionSheet();
        }
    });

    $('.dc-nav a').click(function () {
        $(this).addClass("dc-active").siblings().removeClass("dc-active");
        var id = $(this).data("id");
        $(".dc-foods>div").eq(id - 1).addClass('dc-food-active').siblings().removeClass('dc-food-active');
        $('.dc-food').eq(id-1).find('.dc-menu-wrapper .dc-menu-item').on("click",function(){
            $(this).addClass("dc-active").siblings().removeClass("dc-active");
        })
    });

    $('.dc-food:eq(0)').find('.dc-menu-wrapper .dc-menu-item').on("click",function(){
        $(this).addClass("dc-active").siblings().removeClass("dc-active");
    })
});
